﻿<?php require_once('../Connections/conexao.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

if ((isset($_POST['idadm'])) && ($_POST['idadm'] != "") && (isset($_GET['idadm']))) {
  $deleteSQL = sprintf("DELETE FROM ``admin`` WHERE id_adm=%s",
                       GetSQLValueString($_POST['idadm'], "int"));

  mysql_select_db($database_conexao, $conexao);
  $Result1 = mysql_query($deleteSQL, $conexao) or die(mysql_error());

  $deleteGoTo = "usuario.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
    $deleteGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $deleteGoTo));
}

$colname_rsusuario = "-1";
if (isset($_GET['idadm'])) {
  $colname_rsusuario = $_GET['idadm'];
}
mysql_select_db($database_conexao, $conexao);
$query_rsusuario = sprintf("SELECT * FROM `admin` WHERE id_adm = %s", GetSQLValueString($colname_rsusuario, "int"));
$rsusuario = mysql_query($query_rsusuario, $conexao) or die(mysql_error());
$row_rsusuario = mysql_fetch_assoc($rsusuario);
$totalRows_rsusuario = mysql_num_rows($rsusuario);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- TemplateBeginEditable name="doctitle" -->
<title>Documento sem título</title>
<!-- TemplateEndEditable -->
<!-- TemplateBeginEditable name="head" -->
<!-- TemplateEndEditable -->
</head>

<body>
<table width="960" align="center">
  <tr>
    <td colspan="2">
	<?php include ("../temadmin/cabecalho.php");?>

</td>
  </tr>
  <tr>
    <td colspan="2">
	<?php include "../temadmin/menu_vertical.php";
	?>
    </td>
  </tr>
  <tr>
    <td width="250">
	<?php include "../temadmin/menu.php";?>
    </td>
    <td width="698">
   		
    
    <p>&nbsp;</p>
    <div align="center"><strong>Excluir usuario</strong></div>
    <?php if ( 0 == $row_rsusuario['id_adm'] ) : ?>
    <form method="post" action="">
    <p>&nbsp;</p>
    <p>Você realmente deseja excluir esta usuario?</p>
    <p>
        <input type="submit" value="Sim" />
        <input type="hidden" name="id_adm" value="<?php echo $_GET['idadm']; ?>" />
    </p>
    </form>
<?php else : ?>
    <p>O usuario em questão está em uso. Portanto, ela não poderá ser excluída.</p>
<?php endif; ?>
    
    </td>
  </tr>
  <tr>
    <td colspan="2">
	<?php include ("../temadmin/rodape.php");?>
    </td>
  </tr>
</table>
</body>
</html>
<?php
mysql_free_result($rsusuario);
?>
